package com.example.xiefeihong.chatroom.utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

/**
 * Created by xiefeihong on 17-10-12.
 */

public class DatabaseHelper extends SQLiteOpenHelper {

    private Context context;

    private String createSql = "create table msg(" +
            "id integer primary key autoincrement," +
            "form_user text," +
            "to_user text," +
            "msg text)";

    public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
        this.context = context;
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL(createSql);
        Toast.makeText(context, "database create success", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }

}
